package com;

import com.netty.ServerService;
import com.sokcet.io.ServerSocketIoService;
import io.netty.handler.timeout.IdleStateHandler;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import javax.annotation.Resource;

/**
 * Created by 石头哥哥 on 8/19/16.
 * PACKAGE_NAME:  PACKAGE_NAME
 * COMMENT :
 */
@SpringBootApplication
public class ServerApplication {

    @Resource
    private ServerService serverServiceImpl;


    @Resource
    private ServerSocketIoService serverSocketIoService;

    /**
     * 主程序入口
     *
     * @param args
     */
    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(ServerApplication.class, args);
        ServerApplication serverApplication = (ServerApplication) applicationContext.getBean("serverApplication");

        //do init
        IdleStateHandler idleStateHandler1 = applicationContext.getBean(IdleStateHandler.class);
        IdleStateHandler idleStateHandler2 = applicationContext.getBean(IdleStateHandler.class);


        //start net work
        serverApplication.serverServiceImpl.startServer();
//        serverApplication.serverSocketIoService.statrtServerSocketIo();
    }
}
